home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!netnews
- From: wells2@ix.netcom.com (wells)
- Newsgroups: comp.lang.c++
- Subject: need help with a program mfc
- Date: Sat, 06 Jan 1996 21:11:09 GMT
- Organization: Netcom
- Message-ID: <4cmqhh$arb@ixnews5.ix.netcom.com>
- NNTP-Posting-Host: irv-ca16-17.ix.netcom.com
- X-NETCOM-Date: Sat Jan 06 1:45:21 PM PST 1996
- X-Newsreader: Forte Free Agent 1.0.82
-
-
- I am new to the mfc library and i need some help. I want to take this
- sample prgram and add a second dialog box to it. Can anyone do this so
- i can look it over??? I know i have to add the second dialog to the
- resource but besides that, I want to see how you do it. I have tried
- but i keep getting errors and i dont understand what i am doing wrong.
- I am using Microsoft Visual C++ ver 1.0
-
- thanks you very much in advanced
- i greatly appreaciate it!!!!
- :)
-
-
- here it is......
-
-
-
-
- // hello.cpp : Defines the class behaviors for the application.
- // Hello is a simple program which consists of a main window
- // and an "About" dialog which can be invoked by a menu
- choice.
- // It is intended to serve as a starting-point for new
- // applications.
- //
- // This is a part of the Microsoft Foundation Classes C++ library.
- // Copyright (C) 1992 Microsoft Corporation
- // All rights reserved.
- //
- // This source code is only intended as a supplement to the
- // Microsoft Foundation Classes Reference and Microsoft
- // WinHelp documentation provided with the library.
- // See these sources for detailed information regarding the
- // Microsoft Foundation Classes product.
-
- #include "stdafx.h"
- #include "resource.h"
-
- #include "hello.h"
-
- /////////////////////////////////////////////////////////////////////////////
-
- // theApp:
- // Just creating this application object runs the whole application.
- //
- CTheApp NEAR theApp;
-
- /////////////////////////////////////////////////////////////////////////////
-
- // CMainWindow constructor:
- // Create the window with the appropriate style, size, menu, etc.
- //
- CMainWindow::CMainWindow()
- {
- LoadAccelTable( "MainAccelTable" );
- Create( NULL, "Hello Foundation Application",
- WS_OVERLAPPEDWINDOW, rectDefault, NULL, "MainMenu" );
- }
-
- // OnPaint:
- // This routine draws the string "Hello, Windows!" in the center of
- the
- // client area. It is called whenever Windows sends a WM_PAINT
- message.
- // Note that creating a CPaintDC automatically does a BeginPaint and
- // an EndPaint call is done when it is destroyed at the end of this
- // function. CPaintDC's constructor needs the window (this).
- //
- void CMainWindow::OnPaint()
- {
- CString s = "Hello, Windows!";
- CPaintDC dc( this );
- CRect rect;
-
- GetClientRect( rect );
- dc.SetTextAlign( TA_BASELINE | TA_CENTER );
- dc.SetTextColor( ::GetSysColor( COLOR_WINDOWTEXT ) );
- dc.SetBkMode(TRANSPARENT);
- dc.TextOut( ( rect.right / 2 ), ( rect.bottom / 2 ),
- s, s.GetLength() );
- }
-
- // OnAbout:
- // This member function is called when a WM_COMMAND message with an
- // IDM_ABOUT code is received by the CMainWindow class object. The
- // message map below is responsible for this routing.
- //
- // We create a ClDialog object using the "AboutBox" resource (see
- // hello.rc), and invoke it.
- //
- void CMainWindow::OnAbout()
- {
- CDialog about( "AboutBox", this );
- about.DoModal();
- }
-
- // CMainWindow message map:
- // Associate messages with member functions.
- //
- // It is implied that the ON_WM_PAINT macro expects a member function
- // "void OnPaint()".
- //
- // It is implied that members connected with the ON_COMMAND macro
- // receive no arguments and are void of return type, e.g., "void
- OnAbout()".
- //
- BEGIN_MESSAGE_MAP( CMainWindow, CFrameWnd )
- //{{AFX_MSG_MAP( CMainWindow )
- ON_WM_PAINT()
- ON_COMMAND( IDM_ABOUT, OnAbout )
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CTheApp
-
- // InitInstance:
- // When any CTheApp object is created, this member function is
- automatically
- // called. Any data may be set up at this point.
- //
- // Also, the main window of the application should be created and
- shown here.
- // Return TRUE if the initialization is successful.
- //
- BOOL CTheApp::InitInstance()
- {
- TRACE( "HELLO WORLD\n" );
-
- SetDialogBkColor(); // hook gray dialogs (was default in MFC V1)
-
- m_pMainWnd = new CMainWindow();
- m_pMainWnd->ShowWindow( m_nCmdShow );
- m_pMainWnd->UpdateWindow();
-
- return TRUE;
- }
-
-
-
-